﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knlght.Web.Infrastructure.Menus
{
    /// <summary>
    /// 菜单项
    /// </summary>
    public class MenuItem
    {
        /// <summary>
        /// 菜单项ID
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// 菜单标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 菜单图标类
        /// </summary>
        public string IconClass { get; set; }
        /// <summary>
        /// 菜单链接
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 菜单链接传递的参数
        /// </summary>
        public string UrlParam { get; set; }
        /// <summary>
        /// 下级菜单
        /// </summary>
        public List<MenuItem> Children { get; set; }
        /// <summary>
        /// 上级菜单
        /// </summary>
        public MenuItem Parent { get; set; }

        /// <summary>
        /// 检查对象是否正确
        /// </summary>
        public List<string> Check()
        {
            var errors = new List<string>();
            if (string.IsNullOrWhiteSpace(ID))
            {
                errors.Add("菜单ID不允许为空！");
            }

            if (string.IsNullOrWhiteSpace(Title))
            {
                errors.Add("菜单标题不允许为空!");
            }
            return errors;
        }
        public MenuItem Clone()
        {
            return this.MemberwiseClone() as MenuItem;
        }
    }
}
